package com.axend.sofa.base

import android.os.Bundle
import androidx.databinding.ViewDataBinding
import com.alibaba.android.arouter.launcher.ARouter
import com.axend.lib_base.base.activity.BaseVVDActivity
import com.axend.lib_base.base.vm.BaseViewModel
import com.axend.lib_base.engine.toast.toast
import com.axend.lib_base.help.ble.BleClient
import com.axend.lib_base.utils.ActivityManage
import com.axend.lib_service.ARouterPath

/**
 * @description 蓝牙activity基类
 * @author admins
 * @time 2025/3/4 13:47
 */
abstract class BaseBleVVDActivity<VM : BaseViewModel, VB : ViewDataBinding> :
    BaseVVDActivity<VM, VB>() {

    override fun init(savedInstanceState: Bundle?) {
        /*蓝牙状态监听*/
        BleClient.setDeviceConnectListener { device ->
            if (device.isDisconnected) {
                //蓝牙断开处理
                ActivityManage.finishAllActivity()
                ARouter.getInstance().build(ARouterPath.ACTIVITY_MAIN_BLE).navigation(this)
                toast(getString(com.axend.lib_base.R.string.app_device_disconnected))
            }

        }
    }
}